package com.vanhon.engine.decrypt;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import net.lingala.zip4j.util.InternalZipConstants;

/* compiled from: DecryptStream.java */
/* loaded from: classes.dex */
class DecryptFileSource implements DecryptSource {
    private RandomAccessFile mFile;

    @Override // com.vanhon.engine.decrypt.DecryptSource
    public boolean open(String str) {
        try {
            this.mFile = new RandomAccessFile(str, InternalZipConstants.READ_MODE);
            return true;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override // com.vanhon.engine.decrypt.DecryptSource
    public void close() {
        RandomAccessFile randomAccessFile = this.mFile;
        if (randomAccessFile == null) {
            return;
        }
        try {
            randomAccessFile.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override // com.vanhon.engine.decrypt.DecryptSource
    public long length() throws IOException {
        RandomAccessFile randomAccessFile = this.mFile;
        if (randomAccessFile != null) {
            return randomAccessFile.length();
        }
        return 0L;
    }

    @Override // com.vanhon.engine.decrypt.DecryptSource
    public void seek(long j) throws IOException {
        RandomAccessFile randomAccessFile = this.mFile;
        if (randomAccessFile != null) {
            randomAccessFile.seek(j);
        }
    }

    @Override // com.vanhon.engine.decrypt.DecryptSource
    public int read(byte[] bArr, int i, int i2) throws IOException {
        RandomAccessFile randomAccessFile = this.mFile;
        if (randomAccessFile != null) {
            return randomAccessFile.read(bArr, i, i2);
        }
        return -1;
    }

    @Override // com.vanhon.engine.decrypt.DecryptSource
    public int read(byte[] bArr) throws IOException {
        RandomAccessFile randomAccessFile = this.mFile;
        if (randomAccessFile != null) {
            return randomAccessFile.read(bArr);
        }
        return -1;
    }
}
